<?php
	session_start();	
?>

<?php
	if( $_SESSION["admin"] != "" )
	{
?>
<a href="index.php?com=categoryproduct"><b>List categoryproduct</b></a> | <a href="index.php?com=categoryproduct&func=add"><b>Add categoryproduct</b></a>
<?php
	include_once("process/categoryproduct.php");	
	$categoryproduct = new categoryproduct();
	
	if( $_GET["com"] == "categoryproduct" && $_GET["func"] == "update" && isset($_GET["id"]))
	{
		$row = $categoryproduct->GetOneCategoryProduct($_GET['id']);	
	}elseif( isset($_POST['btnUpdate']) )
	{	
        	
		$CategoryID = stripcslashes($_POST["CategoryID"]);
    		$ProductID=stripcslashes($_POST["ProductID"]);
              $id = stripcslashes($_POST["CPID"]);
            if($CategoryID != "" && $CategoryID != 0 && $ProductID != "" && $ProductID != 0)
            {
        		$categoryproduct->UpdateCategoryProduct($CategoryID, $ProductID, $id);	
        		echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=categoryproduct" />';
        		return;
            }
       
	}
	else
	{
		echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=categoryproduct" />';
	}	
	
?>
<form action="index.php?com=categoryproduct&func=update" method="post" id="contactform" enctype="multipart/form-data">
	<table width="630px" style="font-weight:bold; font-size:10pt;" border="0">
		<tr>
			<td align="center" colspan="4" height="50"><b style="font-size:12pt; color:Blue;">Update categoryproduct</b></td>
		</tr>
		<tr height="26">
			<td align="right" width="120px">Category :&nbsp;&nbsp;
				<input type="hidden" name="CPID" id="CPID" value="<?php echo $row['CPID'] ?>" />
			</td>
			<td width="140px"><input type="text" class="validate[required]" name="CategoryID" id="CategoryID" value="<?php echo $row['CategoryID']; ?>" style="width: 120px;" /><font style="color: red;"> *</font>
				<input type="hidden" name="CPID" id="CPID" value="<?php echo $row['CPID'] ?>" />
			</td>
        </tr>
        <tr>
			<td align="right" width="120px">Product :&nbsp;&nbsp;</td>
			<td><input type="text" class="validate[required]" name="ProductID" id="ProductID" value="<?php echo $row['ProductID']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>  	    
		<tr>
			<td></td>
			<td colspan="3" height="40">
				<input type="submit" name="btnUpdate" id="btnUpdate" value="Update" />
				<input type="reset" value="Reset" />
			</td>
		</tr>
    </table>
</form><br><br>
<i>Please fill in these fields (<font style="color: red;">*</font>)</i>
<?php
    }
   else
	{
		echo "<meta http-equiv='refresh' content='0; url=login.php' />";
	}
?>